package cn.tedu.csmall.stock.webapi.consume;

import cn.tedu.csmall.stock.webapi.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
//去监听RabbitMQ的队列
@RabbitListener(queues = {RabbitMQConfig.STOCK_QUEUE})
public class RabbitMQConsumer {
    //一个类中，只能有一个方法使用该注解
    //方法中声明的对象类型就是从队列中接收消息后会自动转化的类型
    @RabbitHandler
    public void process(LocalDateTime now){
        System.out.println("接收到消息："+ now);
    }
}
